package com.leokok.jts.learning.jts.core.algorithm;

import org.junit.Test;
import org.locationtech.jts.algorithm.InteriorPoint;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;

/**
 * 获取内部点　　
 *
 * Dimension 2 - the interior point is constructed in the middle of the longest interior segment of a line bisecting the area.
 * Dimension 1 - the interior point is the interior or boundary vertex closest to the centroid.
 * Dimension 0 - the point is the point closest to the centroid.
 */
public class InteriorTest {

    @Test
    public void interiorPoint() throws ParseException {
        WKTReader wktReader = new WKTReader();
        /*Geometry geometry = wktReader.read("LINESTRING (115.9234 31.99, 115.9243 31.9898, 115.9266 31.9896, 115.92673333333333 31.9896, 115.9299 31.9895, 115.93 31.989466666666665, 115.9314 31.9894, 115.9315 31.989366666666665, 115.93163333333334 31.989333333333335, 115.9339 31.9892, 115.937 31.989)");*/
        Geometry geometry = wktReader.read("POLYGON ((115.9274 31.9909, 115.9268 31.9903, 115.9266 31.9895, 115.9275 31.9889, 115.929 31.989, 115.9295 31.9899, 115.9292 31.9907, 115.9283 31.9911, 115.9274 31.9909))");

        Coordinate coordinate = InteriorPoint.getInteriorPoint(geometry);
        System.out.println(coordinate);
    }
}
